import {Component, OnInit, Input} from '@angular/core';
import {HttpService} from '../../shared/service/http.service';
import {Router} from '@angular/router';
import {AppGlobalService} from '../../shared/service/app-global.service';

@Component({
    selector: 'app-project-list',
    templateUrl: './project-list.component.html',
    styleUrls: ['./project-list.component.scss']
})
export class ProjectListComponent implements OnInit {
    @Input() tagData: any;

    constructor(
        private http: HttpService,
        private router: Router,
        private appGlobalService: AppGlobalService
    ) {
    }

    img: any;
    list: Array<any>;
    targetObj: any;

    ngOnInit() {
        console.log(this.tagData);
        this.list = this.tagData['projectListItem'];
        this.img = ['https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS5afJLVszYUGNZewOnINKQ-HwxDq-Bj9dDFWdRCNZMc-Kk9_PI'];
    }

    jumpToPage(item) {
        console.log(item);
        let sessionId = localStorage.getItem('sessionId');
        let pageParams = {
            pageId: item.target,
            params: {},
            sessionId: sessionId
        };
        // this.targetObj = {
        //     path : "home/nav",
        //     forward : pageParams,
        //     bat: [],
        //     way: 'page'
        // }
        this.appGlobalService.goToForward(pageParams);
        // localStorage.setItem('targetObj', JSON.stringify(this.targetObj));
        // this.targetObj.bat.push(this.targetObj.forward)
        // this.router.navigate(['home/navTwo'], { queryParams: this.targetObj.forward });
    }

    redirectToPost() {
        const params = {
            pageId: 503,
            params: {
                id: '5c19b285e377bb14d466d16e',
            },
            sessionId: '1c1e0488-4b95-4061-89ea-37240927d611'
        };
        this.appGlobalService.goToForward(params);
    }

    show:boolean = false;
    showSelectModal(){
        this.show = true
    }
}
